//acwing 789
#include<bits/stdc++.h>
using namespace std;
int arrlen,quescnt;
int *arr;

int b_search_upper(int q[],int l,int r,int target){ 
	//find >=target res = index   q[index+1] > target (if exist)
	 int mid;
	 while(l<r){
	 	mid = (l+r+1)>>1;//upper bound must ceil_int
		if (q[mid]<=target) l = mid ; //  2 2 2 3  find 2 (return 2)
		else   r = mid - 1 ;
	 }
	  if (q[l]!=target) return -1;//not found
	 else return l;
}	
int b_search_lower(int q[],int l,int r,int target){ 
	//find <=target res = index   q[index-1] <target (if exist)
	int mid;
	 while(l<r){
	 	mid = (l+r)>>1;
		if (q[mid]<target) l = mid + 1;//easy (normal method)
		else   r = mid;
	 }
	 if (q[l]!=target) return -1;//not found
	 else return l;
}

int main(){
	freopen("data.txt","r",stdin);
	cin>>arrlen;cin>>quescnt;
	arr = new int[arrlen];//[0,arrlen-1]
	for(int i=0;i<arrlen;i++){
		cin>>arr[i];
	}
	for(int i=0;i<quescnt;i++){
		int findNum;cin>>findNum;
		int fbegin = 0,fend = arrlen-1;
		fend = b_search_upper(arr,0,arrlen-1,findNum);  
		fbegin = b_search_lower(arr,0,arrlen-1,findNum);
		cout<<fbegin<<" "<<fend<<endl;	
	}

	
	return 0;
}


